import os

def remove_file(file_path):
    if os.path.exists(file_path):
        os.remove(file_path)
        print('Delete ' + file_path)

txt_files_path = 'ImageSets/Main'
if os.path.exists(txt_files_path):
    file_trainval = txt_files_path + '/trainval.txt'
    remove_file(file_trainval)
    file_test = txt_files_path + '/test.txt'
    remove_file(file_test)
    file_train = txt_files_path + '/train.txt'
    remove_file(file_train)
    file_val = txt_files_path + '/val.txt'
    remove_file(file_val)

labels_path = 'labels'
if os.path.exists(labels_path):
    total_labels = os.listdir(labels_path)
    for label_file in total_labels:
        if label_file[-4:] == '.txt':
            # print(label_file)
            remove_file(labels_path + '/' +label_file)


